import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation } from '@angular/core';
import { environment } from '../../../../environments/environment';
import { I18NService } from '@shared';

@Component({
  selector: 'app-changelog',
  templateUrl: './changelog.component.html',
  styleUrls: ['./changelog.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
})
export class ChangelogComponent implements OnInit {
  prefix = environment.baseUrl;
  markdown;
  markdownUrl;

  constructor(public i18n: I18NService) {}

  ngOnInit(): void {
    this.markdownUrl = `${this.prefix}assets/live/CHANGELOG.md`;
  }

  onLoad(e) {
    const index = e.indexOf('----------');
    this.markdown = e.substring(index);
  }

  onError(e) {
    console.warn(e);
  }
}
